Real-time rendering of light-scattering media

ABSTRACT

A real-time algorithm for rendering of an inhomogeneous scattering media such as smoke under dynamic low-frequency environment lighting is described. An input media animation is represented as a sequence of density fields, each of which is represented by an approximate model density field and a residual density field. The algorithm uses the approximate model density field to compute an approximate source radiance, and further computes an effective exitant radiance by compositing the approximate source radiance using a compositing methods such as ray marching. During the compositing process (e.g., ray marching), the residual field is compensated back into the radiance integral to generate images of higher detail.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation-in-part of application Ser. No.11/768,894 filed on Jun. 26, 2007, entitled “Real-Time Rendering ofLight-Scattering Media”, the entire contents of which are herebyincorporated by reference.

BACKGROUND

Computer graphics systems are used in many game and simulationapplications to create atmospheric effects such as fog, smoke, clouds,smog and other gaseous phenomena. These atmospheric effects are usefulbecause they create a more realistic sense of the environment and alsocreate the effect of objects appearing and fading at a distance.

Extensive research has been done on realistic simulation ofparticipating media, such as fog, smoke, and clouds. The existingmethods includes analytic methods, stochastic methods, numericalsimulations, and pre-computation techniques. Most of these techniquesfocus on computing the light distribution through the gas and presentvarious methods of simulating the light scattering from the particles ofthe gas. Some resolve multiple scattering of light in the gas and othersconsider only first order scattering (the scattering of light in theview direction) and approximate the higher order scattering by anambient light. A majority of the techniques use ray-tracing,voxel-traversal, or other time-consuming algorithms to render theimages.

In some approaches, smoke and clouds are simulated by mappingtransparent textures on a polygonal object that approximates theboundary of the gas. Although the texture may simulate differentdensities of the gas inside the 3D boundary and compute even the lightscattering inside the gas, it does not change, when viewed fromdifferent directions. Consequently, these techniques are suitable forrendering very dense gases or gasses viewed from a distance.

Other methods simplify their task by assuming constant density of thegas at a given elevation, thereby making it possible to use 3D texturesto render the gas in real time. The assumption, however, prevents usingthe algorithm to render inhomogeneous participating media such as smokewith irregular thickness and patchy fog.

There are also methods that use pre-computation techniques in whichvarious scene-dependent quantities are precomputed. The precomputedquantities, however, are valid only for the given static participatingmedium. For dynamic animation sequences with adjustable media (e.g.smoke) parameters, the preprocessing time and storage costs would beprohibitive.

With the existing techniques that do offer quality rendering,considerable simulation time is still needed to render a single image,making these approaches inappropriate for interactive applications onanimated sequences. These methods may also be inadequate to addressescomplex environment illumination. Rendering of smoke, for example,presents a particularly challenging problem in computer graphics becauseof its complicated effects on light propagation. Within a smoke volume,light undergoes absorption and scattering interactions that vary frompoint to point because of the spatial non-uniformity of smoke. In staticparticipating media, the number and complexity of scatteringinteractions lead to a substantial expense in computation. For a dynamicmedium like smoke having an intricate volumetric structure changing withtime, the computational costs can be prohibitive. Even with the latestcomputational processing power, rendering large volume high qualityimages of a dynamic smoke scene can be time-consuming. For video andanimation applications, if real-time rendering at a rate of at leasttwenty frames per second cannot be achieved, much of the rendering mayneed to be precomputed at a cost of losing flexibility and interactivefeatures.

Despite the practical difficulties of rendering inhomogeneous lightscattering media (e.g., smoke), such rendering nevertheless remains apopular element in many applications such as films and games. From anend user's point of view, what is needed is an ability to render inreal-time complex scenes with high quality visual realism. From adesigner's point of view, what is needed is affordable real-time orclose to real-time control over the lighting environment and vantagepoint, as well as the volumetric distribution and optical properties ofthe smoke.

SUMMARY

Real-time rendering inhomogeneous scattering media animations (such assmoke animations) with dynamic low-frequency environment lighting andcontrollable smoke attributes is described. An input media animation isrepresented as a sequence of density fields, each of which isrepresented by an approximate model density field and a residual densityfield. The algorithm uses the approximate model density field to computean approximate source radiance, and further computes an effectiveexitant radiance by compositing the approximate source radiance using acompositing methods such as ray marching. During ray marching, theresidual field is compensated back into the radiance integral togenerate images of higher detail.

In one embodiment, the effective exitant radiance includes a basecomponent and a compensation component. The base component is computedby integrating the approximate source radiance along a view ray in theapproximate model density field, while the compensation component iscomputed by integrating the approximate source radiance along the viewray in the residual density field.

In some embodiments, the approximate model density field is decomposedinto a weighted sum of a set of radial basis functions (RBFs). Sourceradiances from single and optionally multiple scattering are directlycomputed at only the RBF centers and then approximated at other pointsin the volume using an RBF-based interpolation. To further speed up thecomputation, data compression is applied to compress the values of theresidual density field.

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used as an aid in determining the scope of the claimed subjectmatter.

BRIEF DESCRIPTION OF THE FIGURES

The detailed description is described with reference to the accompanyingfigures. In the figures, the left-most digit(s) of a reference numberidentifies the figure in which the reference number first appears. Theuse of the same reference numbers in different figures indicates similaror identical items.

FIG. 1 is a flowchart of an exemplary process for rendering aninhomogeneous scattering medium.

FIG. 2 is a flowchart of an exemplary process of rendering aninhomogeneous scattering medium using a RBF model density field.

FIG. 3 is a flowchart of another exemplary process of rendering aninhomogeneous scattering medium.

FIG. 4 is a flowchart of another exemplary process of rendering aninhomogeneous scattering medium.

FIG. 5 is a flowchart of another exemplary process of rendering aninhomogeneous scattering medium.

FIG. 6 shows an exemplary environment for implementing the method forrendering inhomogeneous scattering media.

FIG. 7 is a diagrammatic illustration of light transport in smoke.

FIG. 8 is an illustration of density field approximation using aresidual density field.

FIG. 9 is a diagram showing an accumulative optical depth of an RBF.

FIG. 10 is an illustration of an exemplary multiple scatteringsimulation for estimation of incident radiance at RBF center c₁.

FIG. 11 is a flowchart of an exemplary GPU pipeline for multiplescattering simulation.

FIG. 12 is an illustration of an exemplary ray marching for radianceintegration along view rays.

DETAILED DESCRIPTION Overview

Several exemplary processes for rendering an inhomogeneous scatteringmedium are illustrated with reference to FIGS. 1-5. The order in whichthe processes described is not intended to be construed as a limitation,and any number of the described method blocks may be combined in anyorder to implement the method, or an alternate method.

FIG. 1 is a flowchart of an exemplary process for rendering aninhomogeneous scattering medium. The process 100 starts at block 101where the original density field of an inhomogeneous scattering mediumis provided. The original density field is represented by the sum of anapproximate model density field and a residual density field. Typically,the approximate model density field is first obtained by modeling theoriginal density field, and the residual density field is then taken asthe difference between the original density field and the approximatemodel density field. Further detail of the modeling is described inlater sections of this description.

At block 110, the process computes an approximate source radiance basedon the approximate model density field. Further detail of thecompetition is described in later sections of this description.

At block 120, the process computes an effective exitant radiance bycompositing the approximate source radiance along a view ray. In oneembodiment, the approximate source radiance is composited by integratingthe approximate source radiance in both the approximate model densityfield and the residual density field. This approximation takes at leastpartial account of the effect of the residual density field. Forexample, the effective exitant radiance may include a base component anda compensation component. As will be shown in further detail below, thebase component is computed by integrating the approximate sourceradiance along a view ray in the approximate model density field, whilethe compensation component is computed by integrating the approximatesource radiance along the view ray in the residual density field. It isappreciated that given the framework of the approximation and theassociated computation as described herein, the actual computation maybe accomplished in a variety of ways. For example, the approximatesource radiance component and the compensation component may be computedseparately first. Alternatively, the effective existent radiance may becomputed using a combined procedure in which the approximate sourceradiance and the compensation component are computed concurrently.Exemplary equations for such computation will be provided along with thedetailed description of algorithms below.

At block 130, the process renders an image of the inhomogeneousscattering medium based on the effective exitant radiance.

As will be described in further below, the approximate source radiancemay be composited by performing a ray marching procedure which includesdecomposing a volume space of the density field into a plurality ofslices along a central view frustum and calculating a discrete integralof the approximate source radiance slice by slice.

An exemplary approximate model density is a RBF model density fieldwhich is expressed by a weighted sum of a set of radial basis functions(RBFs) each having a RBF center. Further detail of using a RBF modeldensity field is discussed below.

FIG. 2 is a flowchart of an exemplary process of rendering aninhomogeneous scattering medium using a RBF model density field. In thisexemplary process, the RBF model density field is only an approximationof an actual density field. A residual density field is used tocompensate the RBF model density field to more closely simulate theactual density field.

The process 200 starts at block 202 at which a RBF model density fieldis provided. The RBF model density field is a weighted sum of a set ofradial basis functions (RBFs) each having a RBF center. The RBF modeldensity field may be provided in various manners and circumstances. Forexample, the RBF model density field may have been previously acquiredas a result of decomposing an actual density field. The decomposition ofthe actual density field may either be done in the same process 200 ofFIG. 2, or in a different process at a different location by a differentparty.

At block 204, a residual density field is provided. The sum of the RBFmodel density field and the residual density field defines an overalldensity field which is more realistic.

At block 206, the process computes a model source radiance in the volumespace for the RBF model density field. The techniques (e.g., theinterpolation technique) described herein may be used for calculatingthe model source radiance in the volume space. For example, the process200 may first compute the value of source radiance at each RBF center.Detail of such computation is described later with the illustration ofexemplary embodiments. As will be shown, computing the values of thesource radiance at RBF centers only (instead of the values at all voxelpoints in the volume space) for the RBF model density field simplifiesthe computation, and can be carried out real time at a video oranimation rate (e.g., at least 10 frames per second, or preferably 20frames per second or above). The process 200 then approximates thevalues of the source radiance at other points in the volume space byinterpolating from the values of the source radiance at the RBF centers.Any suitable interpolation technique may be used. In particular, aspecial interpolation technique is described herein which approximatesthe source radiance at any point x as a weighted combination of thesource radiances at the RBF centers. Interpolation is a much fasterprocess than directly computing the values of source radiance at variousvoxels in the volume space, especially when the direct computationrequires a physics-based simulation.

At block 208, the process computes effective exitant radiance at point xin the volume space based on the model source radiance by taking intoaccount contributions by the residual density field. The point x can beany point in the 3-D volume space. The effective exitant radiance isthus computed as a function of x. Similar to that in FIG. 1, lacking ananalytical form, the effective exitant radiance is calculated atdiscrete points x, each corresponding to a discrete voxel. The effectiveexitant radiance is calculated based on several input informationincluding the reduced incident radiance, the source radiance at eachvoxel, and the density field. Various degrees of approximation may betaken in the process of the computation, as discussed in detail with theexemplary embodiments sections of this description. In one exemplaryembodiment, while the model source radiance is used as an approximationof the total source radiance, the density field includes the residualdensity field to result in an effective exitant radiance more realisticthan the result obtained from using a simple RBF model density fieldalone.

At block 210, the process renders an image of the inhomogeneousscattering medium based on the effective exitant radiance.

FIG. 3 is a flowchart of another exemplary process of rendering aninhomogeneous scattering medium. This exemplary process is a variationof the exemplary process shown in FIG. 2. Like that in FIG. 2, the RBFmodel density field is only an approximation of an actual density field.A residual density field of an inhomogeneous scattering medium is usedto compensate the RBF model density field to more closely simulate theactual density field. In the process 300 of FIG. 3, however, an existingrealistic automotive density is first provided. The process 300 startsat block 302 by decomposing the given density field into a weighted sumof a set of radial basis functions (RBFs) each having a RBF center. Theweighted sum of the set of RBFs gives a RBF model density field which isan approximate representation of the actual density field.

At block 304, the process computes a residual density field whichcompensates the difference between the density field and the RBF modeldensity field residual density field. In a straightforward example, theresidual density field is obtained by calculating the difference betweenthe density field and the RBF model density field residual densityfield. The sum of the RBF model density field and the residual densityfield defines a more realistic overall density field of theinhomogeneous scattering medium.

At block 306, the process computes a model source radiance in the volumespace for the RBF model density field. This step is similar to that inblock 206 of FIG. 2.

At block 308, the process computes effective exitant radiance at point xin the volume space based on the model exitant radiance by taking intoaccount contributions by the residual density field. This step issimilar to that in block 208 of FIG. 2.

At block 310, the process renders an image of the inhomogeneousscattering medium based on the effective exitant radiance. This step issimilar to that in block 210 of FIG. 2.

FIG. 4 is a flowchart of another exemplary process of rendering aninhomogeneous scattering medium. Like that in FIGS. 2-3, the RBF modeldensity field is only an approximation of an actual density field. Aresidual density field of an inhomogeneous scattering medium is used tocompensate the RBF model density field to more closely simulate theactual density field. The process 400 of FIG. 4 introduces a techniquefor faster processing the residual density field. The process 400 startsat block 402 by decomposing the given density field into a weighted sumof a set of radial basis functions (RBFs) each having a RBF center. Theweighted sum of the set of RBFs gives a RBF model density field which isan approximate representation of the actual density field.

At block 404, the process computes a residual density field whichcompensates the difference between the density field and the RBF modeldensity field residual density field.

At block 406, the process compresses the values of the residual densityfield. Because the residual density field tends to have small values atmost points in the volume space, the entries of the residual densityfield at points where the residual density field has a value at or belowa given threshold may be made zero to result in sparsity. This sparsitymay be advantageously used to simplify and speed up the calculations. Aswill be shown in further detail in the exemplary embodiments describedherein, in one embodiment, the residual density field is compressed byperforming a spatial hashing on values of the residual density field.

At block 408, the process computes effective exitant radiance at point xin the volume space by taking into account contributions by both the RBFmodel density field and the residual density field.

At block 410, the process renders an image of the inhomogeneousscattering medium based on the effective exitant radiance.

As will be shown in further detail with exemplary embodiments, thesource radiance may be computed by counting the single scattering termonly. For more accurate and more realistic rendering, however, thesource radiance is preferably computed to include both the singlescattering term and multiple scattering terms.

FIG. 5 is a flowchart of another exemplary process of rendering aninhomogeneous scattering medium. In this exemplary process, the RBFmodel density field may either be an exact representation of the actualdensity or only an approximation of an actual density. In the lattercase, a residual density field may be used to compensate the RBF modeldensity field to more closely simulate the actual density field.

The process 500 starts at block 502 at which a RBF model density fieldis provided. The RBF model density field is a weighted sum of a set ofradial basis functions (RBFs) each having a RBF center. The RBF modeldensity field may be provided in various manners and circumstances. Forexample, the RBF model density field may have been previously acquiredas a result of decomposing an actual density field. The decomposition ofthe actual density field may either be done in the same process 500 ofFIG. 5, or in a different process at a different location by a differentparty.

At block 504, the process computes single scattering source radiance inthe volume space for the RBF model density field. To simplify thecomputation, single scattering source radiance may be computed at RBFcenters first and then interpolated to approximate the source radianceat other points in the volume space.

At block 506, the process computes multiple scattering source radiancein the volume space for the RBF model density field by an iterationinitiated with the single scattering source radiance. To simplify thecomputation, the multiple scattering source radiance may be computed atRBF centers first and then interpolated to approximate the sourceradiance at other points in the volume space.

At block 508, the process computes effective exitant radiance at point xin the volume space based on the multiple scattering source radiance.

At block 510, the process renders an image of the inhomogeneousscattering medium based on the effective exitant radiance.

The techniques described herein may be used for rendering a variety ofinhomogeneous scattering media, and is particularly suitable forrendering smoke in video games in which the smoke is a part of a videoor animation having a sequence of renderings of images each rendered ata short time interval (e.g., 1/20 sec to result in 20 frames persecond). In such renderings, as many as possible runtime blocks arepreferably performed in real time at each time interval. For example, insome embodiments, blocks 110-130 of FIG. 1, blocks 206-210 of FIG. 2,blocks 304-310 of FIG. 3, blocks 404-410 of FIG. 4, and blocks 504-510of FIG. 5 are performed in real time. Preferably, other blocks may alsobe performed in real time to enable interactive changing of lighting,viewpoint and scattering parameters. But if unable to be performed inreal time, some steps may be precomputed before the rendering.

For computing the single scattering term, a technique is hereindescribed for computing a transmittance vector {tilde over (τ)}(c_(l))associated with RBF center ca. For example, a spherical harmonic productand a convolution term[(L_(in)*{tilde over (τ)}(c_(l)))*p] is computedto obtain the single scattering, wherein L_(in) is a vector representinga spherical harmonic projection of incident radiance L_(in), {tilde over(τ)}(c_(l)) is transmittance vector associated with RBF center c_(l),and p is a vector representing a spherical harmonic projection of phasefunction p. The notation and further detail are described later withexemplary embodiments.

For computing the source radiance contributed by the multiplescattering, an iteration techniques using a recursive formula is hereindescribed in which a n^(th) order scattering term (n≧1) is firstcomputed, and a (n+1)^(th) order scattering term is then computed basedon the previously computed n^(th) order scattering term. In oneembodiment, a first order, second order . . . , n^(th) order, and(n+1)^(th) scattering terms are computed reiteratively, until the lastscattering term has a magnitude below a user-specified threshold, or auser-specified number of iterations has been reached.

Once the source radiance(s) are obtained, the effective exitant radiance(blocks 108, 208, 308, 408 and 508) may be obtained using a variety ofsuitable techniques. In one embodiment, a ray marching technique is usedto accomplish this. The ray marching technique decomposes the volumespace into N (≧2) slices of a user-controllable thickness Δu stackingalong a current view direction, and calculates slice by slice a discreteintegral of the source radiance arriving at the point x along thecurrent view direction to obtain the effective exitant radiance.

The above-described analytical framework may be implemented with thehelp of a computing device, such as a personal computer (PC) or a gameconsole.

FIG. 6 shows an exemplary environment for implementing the method forrendering inhomogeneous scattering media. The system 600 is based on acomputing device 602 which includes display 610, computer readablemedium 620, processor(s) 630, and I/O devices 640. Program modules 650are implemented with the computing device 600. Program modules 650contains instructions which, when executed by a processor(s), cause theprocessor(s) to perform actions of a process described herein (e.g., theprocesses of FIGS. 1-5) for rendering an inhomogeneous scatteringmedium.

For example, in one embodiment, computer readable medium 620 has storedthereupon a plurality of instructions that, when executed by one or moreprocessors 630, causes the processor(s) 630 to:

(1) compute an approximate source radiance based on an approximate modeldensity field;

(2) compute an effective exitant radiance by compositing the approximatesource radiance; and

(3) render an image of an inhomogeneous scattering medium based on theeffective exitant radiance.

In one embodiment, the RBF model density field is an approximation ofthe density field of the inhomogeneous scattering medium, and the abovecomputation compensates the effective exitant radiance by taking intoaccount a contribution of a residual density field. The residual densityfield compensates for the difference between the density field and theRBF model density field.

In one embodiment, the inhomogeneous scattering medium is a part of avideo or animation. At least some runtime components, such as the abovesteps (2) and (3) are performed in real time at each time intervalduring a runtime. Preferably, other blocks may also be performed in realtime to enable interactive changing of lighting, viewpoint andscattering parameters.

To accomplish real-time rendering, processor(s) 630 preferably includeboth a central processing unit (CPU) and a graphics processing unit(GPU). For speedier rendering, as many as runtime components arepreferably implemented with the GPU.

It is appreciated that the computer readable media may be any of thesuitable memory devices for storing computer data. Such memory devicesinclude, but not limited to, hard disks, flash memory devices, opticaldata storages, and floppy disks. Furthermore, the computer readablemedia containing the computer-executable instructions may consist ofcomponent(s) in a local system or components distributed over a networkof multiple remote systems. The data of the computer-executableinstructions may either be delivered in a tangible physical memorydevice or transmitted electronically.

It is also appreciated that a computing device may be any device thathas a processor, an I/O device and a memory (either an internal memoryor an external memory), and is not limited to a personal computer. Forexample, a computer device may be, without limitation, a PC, a gameconsole, a set top box, and a computing unit built in another electronicdevice such as a television, a display, a printer or a digital camera.

ALGORITHMS AND EXEMPLARY EMBODIMENTS

Further detail of the techniques for rendering an inhomogeneousscattering medium is described below with theoretical background of thealgorithms and exemplary embodiments. The techniques described hereinare particularly suitable for real-time rendering of smoke in alow-frequency environment light, as illustrated below.

Notation and Background:

TABLE 1 lists the notation used in this description.

TABLE 1 Notation x A point in the 3D volume space s, ω Direction x_(ω) Apoint where light enters the medium along direction ω ω_(i), ω_(o)Incident, exitant radiance direction S Sphere of directions D(x) Medium(smoke) density {tilde over (D)}(x) Model density field or approximationdensity R(x) Residual density σ_(t) Extinction cross section σ_(s)Scattering cross section Ω Single-scattering albedo, computed asσ_(s)/σ_(t) κ_(t)(x) Extinction coefficient, computed as σ_(t)D(x) τ(u,x) Transmittance from u to x, computed  as  exp (−∫_(u)^(x)κ_(t)(v) 𝕕v)τ_(∞)(x, ω) Transmittance from infinity to x fromdirection  ω, computed  as  exp (−∫_(x)^(∞_(ω))κ_(t)(v) 𝕕v) L_(in)(ω)Environment map L_(out)(x, ω) Exitant (outgoing) radiance L_(d) Reducedincident radiance L_(m) Medium radiance J(x, ω) Source radiance J_(ss)Source radiance contributed by single scattering J_(ms) Source radiancecontributed by multiple scattering p(ω_(o), ω_(i)) Phase function y(s)Set of spherical harmonic basis functions y_(i)(s), y_(l) ^(m)(s)Spherical harmonic basis function f_(i), f_(l) ^(m) Spherical harmoniccoefficient vector

In this description, the lighting is represented as a low-frequencyenvironment map L_(in), described by a vector of spherical harmoniccoefficients L_(in). A sequence of density fields is used to model theinput smoke animation. At each frame, the smoke density is denoted asD(x).

The light transport in scattering media and operations on sphericalharmonics are first described below.

Light Transport in Scattering Media—To describe light transport inscattering media, several radiance quantities are utilized, which aredefined as in Cerezo, E., et al. “A Survey on Participating MediaRendering Techniques”, the Visual Computer 21, 5, 303-328, 2005.

FIG. 7 is a diagrammatic illustration of light transport in smoke. Asshown in FIG. 7, the exitant radiance at a point x is composed of thereduced incident radiance L_(d) and the medium radiance L_(m):L _(out)(x,ω _(o))=L _(d)(x,ω _(o))+L _(m)(x,ω _(o)).

The reduced incident radiance represents incident radiance L_(in) alongdirection ω_(o) that has been attenuated by the medium before arrivingat x:L _(d)(x,ω _(o))=τ_(∞)(x,ω _(o))L _(in)(ω_(o)).  (1)

The medium radiance L_(m) is the integration of the source radiance Jthat arrives at x along direction ω_(o) from points within the medium:

L_(m)(x, ω_(o)) = ∫_(x_(ω_(o)))^(x)τ(u, x)σ_(t)D(u)J(u, ω_(o))𝕕u.

In non-emissive media such as smoke, this source radiance J is composedof a single scattering J_(ss) and multiple scattering J_(ms) component:J(u,ω _(o))=J _(ss)(u,ω _(o))+J _(ms)(u,ω _(o)).

The single scattering term, J_(ss), represents the first scatteringinteraction of the reduced incident radiance:

$\begin{matrix}{{J_{ss}( {u,\omega_{o}} )} = {\frac{\Omega}{4\pi}{\int_{S}{{L_{d}( {u,\omega_{i}} )}{p( {\omega_{o},\omega_{i}} )}{{\mathbb{d}\omega_{i}}.}}}}} & (2)\end{matrix}$

The multiple scattering term, J_(ms), accounts for scattering of themedium radiance:

$\begin{matrix}{{J_{ms}( {u,\omega_{o}} )} = {\frac{\Omega}{4\pi}{\int_{S}^{\;}{{L_{m}( {u,\omega_{i}} )}{p( {\omega_{o},\omega_{i}} )}{{\mathbb{d}\omega_{i}}.}}}}} & (3)\end{matrix}$

Spherical Harmonics—Low-frequency spherical functions can be efficientlyrepresented in terms of spherical harmonics (SHs). A spherical functionƒ(s) can be projected onto a basis set y(s) to obtain a vector f thatrepresents its low-frequency components:

$\begin{matrix}{f = {f_{s}{f(s)}{y(s)}\;{{ds}.}}} & (4)\end{matrix}$

An order-n SH projection has n² vector coefficients. With thesecoefficients, one can reconstruct a spherical function {tilde over(ƒ)}(s) that approximates ƒ(s):

$\begin{matrix}{{\overset{\sim}{f}(s)} = {{\sum\limits_{i = 0}^{n^{2} - 1}{f_{i}{y_{i}(s)}}} = {f \cdot {{y(s)}.}}}} & (5)\end{matrix}$

The SH triple product, denoted by f*g, represents the order-n projectedresult of multiplying the reconstructions of two order-n vectors:

${{f*g} = { {\int_{S}{{f(s)}{g(s)}{y(s)}{\mathbb{d}s}}}\Rightarrow( {f*g} )_{i}  = {\sum\limits_{j,k}{\Gamma_{ijk}f_{j}g_{k}}}}},$

where the SH triple product tensor Γ_(ijk) is defined as

Γ_(ijk) = ∫_(s) y_(i)(s)y_(j)(s)y_(k)(s) 𝕕s.

Γ_(ijk) is symmetric, sparse, and of order 3.

SH convolution, denoted by f*g, represents the order-n projected resultof convolving the reconstructions of two order-n vectors:

${{f*g} = { {\int_{S}{\int_{S}{{f(t)}{g( {R_{s}(t)} )}{y(s)}{\mathbb{d}t}{\mathbb{d}s}}}}\Rightarrow( {f*g} )_{l}^{m}  = {\sqrt{\frac{4\pi}{{2l} + 1}}f_{l}^{m}g_{l}^{0}}}},$

where g(s) is a circularly symmetric function, and R_(s) is a rotationalong the elevation angle towards direction s (i.e., the angle betweenthe positive z-axis and direction s).

SH exponentiation, denoted by exp*(f), represents the order-n projectedresult of the exponential of a reconstructed order-n vector:

exp  * (f) = ∫_(s) exp (f(s))y(s) 𝕕s.

This can be efficiently calculated on the GPU using the optimal linearapproximation:

${{\exp_{*}(f)} \approx {{\exp( \frac{f_{0}}{\sqrt{4\pi}} )}( {{{a( {\hat{f}} )}1} + {{b( {\hat{f}} )}\hat{f}}} )}},$

where {circumflex over (f)}=(0, f₁, f₂, . . . , f_(n) ₂ ⁻¹), 1=(√{squareroot over (4π)}, 0, 0, . . . , 0), and a, b are tabulated functions ofthe magnitude of input vector {circumflex over (f)}.

The above notation and background forms a basis for the algorithmsdescribed below.

The Algorithms:

The approach illustrated herein consists of a preprocessing step and aruntime rendering algorithm.

Preprocessing—Before the runtime rendering, an input density field isfirst processed using approximation, an example of which is illustratedin FIG. 8.

FIG. 8 is an illustration of density field approximation using aresidual density field. Original volume density D(x) 802 is shown to bethe sum of RBF model density field (RBF approximation) {tilde over(D)}(x) 804 and residual density R(x) 806, which is scaled by sixteentimes for better viewing. Residual density R(x) 806 has both positiveresiduals is negative residuals.

The ordinal density field D(x) is first decomposed into a weighted sumof RBFs B_(l)(x) and a residual R(x):

${D(x)} = {{{\overset{\sim}{D}(x)} + {R(x)}} = {{\sum\limits_{\ell}{w_{\ell}{B_{\ell}(x)}}} + {{R(x)}.}}}$

Each RBF B_(l)(x) is defined by its center c_(l) and radius r_(l):B _(l)(x)=G(∥x−c _(l) ∥,r _(l)),

where G(t,λ) is a radial basis function. An exemplary radio basisfunction suitable for the above decomposition is:

${G( {t,\lambda} )} = \{ \begin{matrix}{{1 - \frac{22t^{2}}{9\lambda^{2}} + \frac{17t^{4}}{9\lambda^{4}} - \frac{4t^{6}}{9\lambda^{6}}},} & {{{ift} \leq \lambda};} \\{0,} & {{otherwise}.}\end{matrix} $

These RBFs are approximately Gaussian in shape, have local support, andare C¹ continuous.

The RBF model density field {tilde over (D)}(x) represents alow-frequency approximation of the smoke density field. In general, theresidual density R(x) contains a relatively small number of significantvalues. To promote compression, the values of R(x) below a giventhreshold may be made to zero, such that the residual becomes sparse.

Runtime—In a participating media simulation, the computational expensemainly lies in the evaluation of source radiances J from the densityfield D. To expedite this process, an approximation {tilde over (J)} ofthe source radiances from the RBF model {tilde over (D)} of the densityfield may be computed. In one specific embodiment, {tilde over (J)} dueto single and multiple scattering at only the RBF centers c_(l) iscomputed as follows:{tilde over (J)}(c _(l))={tilde over (J)} _(ss)(c _(l))+{tilde over (J)}_(ms)(c _(l)).

The source radiance at any point x in the medium may be interpolatedfrom {tilde over (J)}(c_(l)) due to single and multiple scattering atonly the RBF centers c_(l). An exemplary interpolation is to approximatethe source radiance at any point x as a weighted combination of thesource radiances at these centers:

${{J( {x,\omega_{o}} )} \approx {\overset{\sim}{J}( {x,\omega_{o}} )}} = {\frac{1}{\overset{\sim}{D}(x)}{\sum\limits_{\ell}{w_{\ell}{B_{\ell}(x)}{{\overset{\sim}{J}( {c_{\ell},\omega_{o}} )}.}}}}$

The single scattering and multiple scattering source radiances in asmoke volume may be used as a rough approximation to render images ofthe medium (smoke). For volumetric rendering, source radiances (singlescattering and/or multiple scattering) are integrated along the view rayfor the final rendering. In some embodiments, ray marching method asdescribed herein may be used for such integration after computation ofsource radiances. The ray marching process is to compute the mediumradiance L_(m)(x,ω_(o)) by gathering radiance contributions towards theviewpoint. The medium radiance L_(m)(x,ω_(o)) is further used to computethe final exitant radiance L_(out)(x,ω_(o)). Further detail of the raymarching process is discussed in a later section of this description.

In computing the medium radiance L_(m)(x,ω_(o)), various degrees ofapproximation may be taken. A basic level (zero order) approximation isto take component {tilde over (L)}_(m) computed from the approximatedsource radiances {tilde over (J)} and the RBF density model as themedium radiance L_(m)(x,ω_(o)). At high levels of approximation,radiance contributions including the component {tilde over (L)}_(m) anda component {tilde over (C)}_(m) that compensates for the density fieldresidual may be taken into account:

$\begin{matrix}\begin{matrix}{{L_{m}( {x,\omega_{o}} )} \approx {{{\overset{\sim}{L}}_{m}( {x,\omega_{o}} )} + {{\overset{\sim}{C}}_{m}( {x,\omega_{o}} )}}} \\{= {{\sum\limits_{j = 1}^{N}{{\overset{\sim}{\tau}( {x_{j},x} )}\sigma_{t}{\overset{\sim}{D}( x_{j} )}{\overset{\sim}{J}( {x_{j},\omega_{o}} )}}} +}} \\{{\sum\limits_{j = 1}^{N}{{\overset{\sim}{\tau}( {x_{j},x} )}\sigma_{t}{R( x_{j} )}{\overset{\sim}{J}( {x_{j},\omega_{o}} )}}},}\end{matrix} & (6)\end{matrix}$

where {tilde over (τ)} denotes transmittance values computed from {tildeover (D)}, and x_(j) indexes a set of N uniformly distributed pointsbetween x_(ω) _(o) and x. The above approximation described in equation(6) may be seen as a first order approximation.

The compensation term {tilde over (C)}_(m) brings into the ray march theextinction effects of the density residuals, resulting in a significantimprovement over the zero order approximation. Theoretically,transmittance τ computed from exact density D (rather than theapproximate transmittance {tilde over (τ)} computed from the RBFapproximate density {tilde over (D)}) and the exact source radiance J(rather than the approximate source radiance {tilde over (J)}) may beused for an even higher order of approximation. However, the improvementover the first order approximation may not worth the increasedcomputational cost.

Due to its size, a density field D cannot in general be effectivelyprocessed on the GPU. However, the decomposition of a density field intoan RBF approximation and a residual field leads to a considerablereduction in data size. Because of its sparsity, it is observed that theresidual can be highly compressed using hashing such as the perfectspatial hashing technique. In addition to providing manageable storagecosts, perfect spatial hashing also offers fast reconstruction of theresidual in the ray march. By incorporating high-frequency smoke detailsin this manner, high-quality smoke renderings can be generated.

With the above formulation, it is possible to obtain real-timeperformance with high visual fidelity by accounting for the cumbersomeresidual field only where it has a direct impact on Eq. (6), namely, inthe smoke density values. For these smoke densities, the residual can beefficiently retrieved from the hash table using perfect spatial hashing.In the other factors of Eq. (6), the residual has only an indirecteffect and also cannot be rapidly accounted for. Therefore, someembodiments may exclude the residuals from computations of sourceradiances and transmittances to significantly speed up processingwithout causing significant degradation of smoke appearance, as will beshown in the next section.

Further Algorithm Detail:

Density Field Approximation—Given the number n of RBFs, an optimalapproximation of the smoke density field may be computed by solving thefollowing minimization problem:

$\begin{matrix}{{\min\limits_{c_{\ell},r_{\ell},w_{\ell}}( {\sum\limits_{j,k,l}\lbrack {{D( x_{jkl} )} - {\sum\limits_{\ell = 1}^{n}{w_{\ell}{B_{\ell}( x_{jkl} )}}}} \rbrack^{2}} )},} & (7)\end{matrix}$

where (j, k, l) indexes a volumetric grid point at position x_(jkl). Foroptimization, the algorithm may employ the L-BFGS-B minimizer, which hasbeen used by others to fit spherical RBFs to a lighting environment, andto fit zonal harmonics to a radiance transfer function.

Since L-BFGS-B is a derivative-based method, at each iteration one needsto provide the minimizer with the objective function and the partialderivatives for each variable. For the objective function

${{f( \{ {c_{\ell},r_{\ell},w_{\ell}} \}_{\ell = {1\;\ldots\; n}} )} = {\sum\limits_{j,k,l}( {{D( x_{jkl} )} - {\overset{\sim}{D}( x_{jkl} )}} )^{2}}},$

the partial derivatives for each parameter are given by

$\frac{\partial f}{\partial v} = {\sum\limits_{j,k,l}{2( {{D( x_{jkl} )} - {\overset{\sim}{D}( x_{jkl} )}} )( {- \frac{\partial\overset{\sim}{D}}{\partial v}} )}}$

where v denotes a variable in {c_(l), r_(l), w_(l)}_(l=1 . . . n). Thepartial derivatives of {tilde over (D)} with respect to each variableare

${\frac{\partial\overset{\sim}{D}}{\partial c_{\ell}} = {w_{\ell}( {\frac{44\Delta_{\ell}}{9r_{\ell}^{2}} - \frac{68\Delta_{\ell}{\Delta_{\ell}}^{2}}{9r_{\ell}^{4}} + \frac{8\Delta_{\ell}{\Delta_{\ell}}^{4}}{3r_{\ell}^{6}}} )}},{\frac{\partial\overset{\sim}{D}}{\partial r_{\ell}} = {w_{\ell}( {\frac{44{\Delta_{\ell}}^{2}}{9r_{\ell}^{3}} - \frac{68{\Delta_{\ell}}^{4}}{9r_{\ell}^{5}} + \frac{8{\Delta_{\ell}}^{6}}{3r_{\ell}^{7}}} )}},{\frac{\partial\overset{\sim}{D}}{\partial w_{\ell}} = {G( {{\Delta_{\ell}},r_{\ell}} )}},{{{where}\mspace{14mu}\Delta_{\ell}} = {x_{jkl} - {c_{\ell}.}}}$

Evaluation of these quantities requires iterating over all voxels in thevolume, 100³-128³ for the examples in this paper. To reduce computation,one may take advantage of the sparsity of the smoke data by processingonly voxels within the support range of an RBF. To avoid entrapment inlocal minima at early stages of the algorithm, one may also employ ateleportation scheme, where the algorithm records the location of themaximum error during the approximation procedure and then moves the mostinsignificant basis function there. In one example, teleportations areutilized at every 20 iterations of the minimizer, and when the minimizerconverges the most insignificant RBF is teleported alternatingly to thelocation of maximum error or to a random location with non-zero data.The inclusion of teleportation into the minimization process often leadsto a further reduction of the objective function by 20%-30%.

Depending on the smoke density distribution in each frame, a differentnumber n of RBFs may be utilized to provide a balance between accuracyand efficiency. One exemplary embodiment starts with a large number(1000) of RBFs in each frame, then after optimization by Eq. (7) mergesRBFs that are in close proximity. For example, B_(l) and B_(h) aremerged together if their centers satisfy the condition ∥c_(l)−c_(h)∥<ε.The center of the new RBF is then taken as the midpoint between c_(l)and c_(h). After this merging process, fix the RBF centers and optimizeagain with respect to only r_(l) and w_(l). In one exemplaryimplementation, ε is set to 2Δ, where Δ is the distance betweenneighboring grid points in the volume.

To accelerate this process, one exemplary embodiment takes advantage ofthe temporal coherence in smoke animations by initializing the RBFs of aframe with the optimization result of the preceding frame beforemerging. For the first frame, the initialization is generated randomly.

Residual Field Compression—After computing the RBF approximation of thedensity field, the residual density field R(x)=D(x)−{tilde over (D)}(x)may be compressed for faster GPU processing. While the residual field isof the same resolution as the density field, it normally consists ofsmall values. Entries in R(x) below a given threshold (e.g., 0.005-0.01)may be made zero, and the resulting sparse residual field is compressedusing a hashing technique such as the perfect spatial hashing, which islossless and ideally suited for parallel evaluation on graphicshardware.

One exemplary implementation of perfect spatial hashing utilizes a fewmodifications tailored to rendering inhomogeneous scattering media.Unlike in some cases where nonzero values in the data lie mostly alongthe surface of a volume, the nonzero values in the residual fields forsmoke may be distributed throughout the volume. Larger offset tables aretherefore needed, and as a result the initial table size is set to anexemplary

$\sqrt[3]{K/3} + 9$(K is the number of nonzero items in the volume), instead of

$\sqrt[3]{K/6}$used by others.

One exemplary technique for processing a sequence of residual fields isto tile several consecutive frames into a larger volume on which hashingis conducted. Since computation is nonlinear to the number of domainslots, it may be advantageous to construct a set of smaller hash volumesinstead of tiling all the frames into a single volume. With smaller hashvolumes, the technique may also avoid the precision problems that arisein decoding the domain coordinates of large packed volumes. In oneexemplary implementation, 3³=27 frames per volume are tiled.

Single Scattering—To promote runtime performance, source radiance valuesin the smoke volume may be calculated using {tilde over (D)}, thelow-frequency RBF approximation of the density field. For example,single scattering at the RBF centers may be computed according to Eq.(2):

$\begin{matrix}\begin{matrix}{{{\overset{\sim}{J}}_{ss}( {c_{\ell},\omega_{o}} )} = {\frac{\Omega}{4\pi}{\int_{S}{{{\overset{\sim}{L}}_{d}( {c_{\ell},\omega_{i}} )}{p( {\omega_{o},\omega_{i}} )}{\mathbb{d}\omega_{i}}}}}} \\{{= {\frac{\Omega}{4\pi}{\int_{S}{{L_{in}( \omega_{i} )}{{\overset{\sim}{\tau}}_{\infty}( {c_{\ell},\omega_{i}} )}{p( {\omega_{o},\omega_{i}} )}{\mathbb{d}\omega_{i}}}}}},}\end{matrix} & (8)\end{matrix}$

where

${{\overset{\sim}{\tau}}_{\infty}( {c_{\ell},\omega_{i}} )} = {\exp( {- {\int_{c_{\ell}}^{\infty_{\omega_{i}}}{\sigma_{t}{\overset{\sim}{D}(u)}{\mathbb{d}u}}}} )}$is the approximated transmittance along direction ω_(i) from infinity toc_(l).

In scattering media, phase functions are often well-parameterized by theangle θ between the incoming and outgoing directions. For computationalconvenience, one may therefore rewrite p(ω_(o),ω_(i)) as a circularlysymmetric function p(z), where z=cos θ. With this reparameterization ofthe phase function, Eq. (8) can be efficiently computed using the SHtriple product and convolution:

$\begin{matrix}{{{\overset{\sim}{J}}_{ss}( c_{\ell} )} = {{\frac{\Omega}{4\pi}\lbrack {( {L_{in}*{\overset{\sim}{\tau}( c_{\ell} )}} )*p} \rbrack}.}} & (9)\end{matrix}$

L_(in) and p may be precomputed according to Eq. (4). The transmittancevector {tilde over (τ)}(c_(l)) may be computed on the fly usingefficient techniques described as follows.

Computing the transmittance vector {tilde over (τ)}(c_(l)): Expressingtransmittance directly in terms of the RBFs, one has

$\begin{matrix}{{\overset{\sim}{\tau}( {c_{\ell},\omega_{i}} )} = {\exp( {{- \sigma_{t}}{\sum\limits_{h}{w_{h}{\int_{c_{\ell}}^{\infty_{\omega_{i}}}{{B_{h}(u)}{\mathbb{d}u}}}}}} )}} \\{{= {\exp( {{- \sigma_{t}}{\sum\limits_{h}{w_{h}{T_{h}( {c_{\ell},\omega_{i}} )}}}} )}},}\end{matrix}$

where T_(h)(c_(l),ω_(i)) is the accumulative optical depth through RBFB_(h). {tilde over (τ)}(c_(l)) can then be computed as

${{\overset{\sim}{\tau}( c_{\ell} )} = {\exp_{*}( {{- \sigma_{t}}{\sum\limits_{h}{w_{h}{T_{h}( c_{\ell} )}}}} )}},$

where T_(h)(c_(l)) is the SH projection of T_(h)(c_(l),ω_(i)), and σ_(t)is the extinction cross section.

FIG. 9 is a diagram showing an accumulative optical depth of an RBF B.The accumulated optical depth is shown to be determined by the angle βsubtended by half the RBF and its absolute radius r. For fastevaluation, the precomputed value for a unit-radius RBF B_(u) with angleβ is retrieved, rotated, and then multiplied by r.

For efficient determination of T_(h)(c_(l)), the accumulative opticaldepth vector T(β) may be tabulated with respect to angle β, equal tohalf the subtended angle of a unit-radius RBF B_(u) as illustrated inFIG. 9. Note that β ranges from 0 to π:

$\beta = \{ \begin{matrix}{{\arcsin( {1/d} )},} & {{{if}\mspace{14mu} d} > 1} \\{{{\arccos(d)} + {\pi/2}},} & {otherwise}\end{matrix} $

where d is the distance from c_(l) to the center of B_(u). Since the RBFkernel function G is symmetric, this involves a 1D tabulation of zonalharmonic (ZH) vectors.

At runtime, ZH vectors T(β_(l,h)) are retrieved from the table, whereβ_(l,h) is half the angle subtended by RBF B_(h) as seen from c_(l).T_(h)(c_(l)) is then computed by rotating T(β_(l,h)) to the axisdetermined by c_(l) and c_(h), followed by a multiplication with theradius r_(h).

Computation of the transmittance vector {tilde over (τ)}(c_(l)) is thenstraightforward. For each RBF center, the computation iterates throughthe RBFs. Their accumulative optical depth vectors are retrieved,rotated, scaled, and summed up to yield the total optical depth vector.Finally, the accumulative optical depth is multiplied by the negativeextinction cross section σ_(t) and exponentiated to yield thetransmittance vector {tilde over (τ)}(c_(l)). With this transmittancevector, the source radiance due to single scattering is computed fromEq. (9)

The single scattering approximation yields results similar to thoseobtained from ray tracing. For a clearer comparison, ray tracing wasperformed with the approximated density field {tilde over (D)}(x), andcompared with the single scattering result. In rendering the singlescattering image, the ray marching algorithm described in a latersection of the present description is used but without accounting forthe residual.

Multiple Scattering—Source radiance J_(ms) due to multiple scattering isexpressed in Eq. (3). In evaluating J_(ms), one exemplary approach is tofirst group light paths by the number of scattering events they include:J _(ms)(x,ω _(o))=J _(ms) ²(x,ω _(o))+J _(ms) ³(x,ω _(o))+ . . . .

J_(ms) ^(k) represents source radiance after k scattering events,computed from medium radiance that has scattered k−1 times:

${{J_{ms}^{k}( {x,\omega_{o}} )} = {\frac{\Omega}{4\pi}{\int_{S}{{L_{m}^{k - 1}( {x,\omega_{i}} )}{p( {\omega_{o},\omega_{i}} )}{\mathbb{d}\omega_{i}}}}}},{where}$L_(m)^(k − 1)(x, ω_(o)) = ∫_(x_(ω_(o)))^(x)τ(u, x)σ_(t)D(u)J_(ms)^(k − 1)(u, ω_(o))𝕕u.

In this recursive computation, one may use the single scattering sourceradiance to initialize the procedure:

L_(m)¹(x, ω_(o)) = ∫_(x_(ω_(o)))^(x)τ(u, x)σ_(t)D(u)J_(ss)(u, ω_(o))𝕕u.

Multiple scattering computed above provides a more accurate simulationof the scattering between RBFs than single scattering alone.

In the SH domain, this scheme proceeds as follows. The algorithm firstcomputes at each RBF center the initial radiance distributions fromsingle scattering:

${I^{1}( c_{\ell} )} = {L_{in}*{\overset{\sim}{\tau}( c_{\ell} )}}$${{\overset{\sim}{J}}_{ms}^{1}( c_{\ell} )} = {{{\overset{\sim}{J}}_{ss}( c_{\ell} )} = {\frac{\Omega}{4\pi}( {{I^{1}( c_{\ell} )}*p} )}}$${{E^{1}( c_{\ell} )} = {{\overset{\sim}{J}}_{ms}^{1}( c_{\ell} )}},$

where I and E represent incident and exitant radiance, respectively.Then at each iteration k, the three SH vectors are updated according to

I^(k)(c_(ℓ)) = H({E^(k − 1)(c_(h))})${{\overset{\sim}{J}}_{ms}^{k}( c_{\ell} )} = {\frac{{\alpha( c_{\ell} )}\Omega}{4\pi}( {{I^{k}( c_{\ell} )}*p} )}$${E^{k}( c_{\ell} )} = {{( {1 - {\alpha( c_{\ell} )}} ){I^{k}( c_{k} )}} + {{{\overset{\sim}{J}}_{ms}^{k}( c_{\ell} )}.}}$

Intuitively, one may evaluate the incident radiance from the exitantradiance of the preceding iteration using a process H, which will beexplained later in detail, then compute the scattered source radiance byconvolving the incident radiance with the phase function. Here, α(c_(l))is the opacity of RBF B_(l) along its diameter (i.e., the scatteringprobability of B_(l)), computed by, for example, α(c_(l))=1−e^(−1.7σ)^(t) ^(ω) ^(l) ^(r) ^(l) . Finally, one may add the scattered sourceradiance to the transmitted radiance to yield the exitant (outgoing)radiance.

The simulation runs until the magnitude of E^(k+1)(c_(l)) falls below auser-specified threshold, or until a user-specified number of iterationsis reached. In some exemplary implementations, this process typicallyconverges in 5-10 iterations.

Estimation of Incident Radiance I^(k)(c_(l)): The process H mentionedearlier for estimating incident radiance is explained as follows. Toestimate the incident radiance at an RBF center c_(l), one may considereach of the RBFs in its neighborhood as a light source that illuminatesc_(l), as illustrated in FIG. 10.

FIG. 10 is an illustration of an exemplary multiple scatteringsimulation for estimation of incident radiance at RBF center c₁ of RBFB₁.

The illumination from RBF B_(h) is approximated as that from a uniformspherical light source, whose intensity E_(l,h) ^(k−1) in directionc_(l)−c_(h) is reconstructed from the SH vector E^(k−1)(c_(h)) using Eq.(5):E _(l,h) ^(k−1) =E ^(k−1)(c _(h))·y(s(c _(l) ,c _(h))),where

${s( {c_{\ell},c_{h}} )} = \frac{c_{\ell} - c_{h}}{{c_{\ell} - c_{h}}}$represents the direction from c_(h) to c_(l).

The SH vector for a uniform spherical light source can be represented asa zonal harmonic vector, and tabulated with respect to the angle θ,equal to half the subtended angle by a spherical light source of unitradius. Unlike β in a single scattering, θ ranges from 0 to π/2 suchthat c_(l) does not lie within a light source. From this precomputedtable, one can retrieve the SH vector using the angle θ_(l,h), which ishalf the angle subtended by RBF B_(h) as seen from point c_(l):

$\theta_{\ell,h} = \{ \begin{matrix}{{\arcsin( {r_{h}/{{c_{\ell} - c_{h}}}} )},} & {{{{if}\mspace{14mu}{{c_{\ell} - c_{h}}}} > r_{h}};} \\{{\pi/2},} & {{otherwise}.}\end{matrix} $

Note that in FIG. 10, the angle θ_(1,3) (θ with respect to RBFs B₁ andB₃) is equal to π/2 because c₁ of RBF B₁ is located within RBF B₃.

The vector is then rotated to direction c_(l)−c_(h), scale it bymin(r_(h),∥c_(l)−c_(h)∥) to account for RBF radius, and finally multiplyit by the intensity E_(l,h) ^(k−1) to obtain the SH vector I_(l,h) ^(k).The incident radiance I^(k)(c_(l)) at c_(l) is then computed as:

${{I^{k}( c_{l} )} = {\sum\limits_{{{c_{l} - c_{h}}} < {\rho\; l}}^{\;}\;{{\overset{\sim}{\tau}( {c_{l},c_{h}} )}I_{l,h}^{k}}}},$

where the parameter ρ_(l) is used to adjust the neighborhood size. Inone exemplary implementation, the default value of ρ_(l) is 2r_(l).

The source radiance for different numbers of scattering events isaggregated to obtain the final source radiance due to multiplescattering:

${{\overset{\sim}{J}}_{ms}( c_{l} )} = {\sum\limits_{k = 2}^{\;}\;{{{\hat{J}}_{ms}^{k}( c_{l} )}.}}$Combining this with the single-scattering component yields the finalsource radiance:{tilde over (J)}(c _(l))={tilde over (J)} _(ss)(c _(l))+{tilde over (J)}_(ms)(c _(l)).

FIG. 11 is a flowchart of an exemplary GPU pipeline for multiplescattering simulation. This is a GPU implementation of theabove-described multiple scattering simulation The detail is furtherdescribed in a later section for GPU implementation.

The multiple scattering result obtained using the above-described methodhas been compared with that from the offline algorithm for volumetricphoton mapping. Although the algorithm described herein employs severalapproximations in the multiple scattering simulation, the two resultsare comparable in terms of image quality. In the comparison, one millionphotons are used in computing the volume photon map. A forward ray marchis then performed to produce the photon map image.

Compensated Ray Marching—From the source radiances at the RBF centers,the source radiance of each voxel in the volume is obtained byinterpolation as described herein. With the complete source radiance,one may perform a ray march to composite the radiances along each viewray.

FIG. 12 is an illustration of an exemplary ray marching for radianceintegration along view rays. To calculate the radiance of a view ray1202, all voxels that the view ray 1202 intersects are traversed fromback (the side close to the viewpoint 1204) to front (beside opposite tothe viewpoint 1204). The initial radiance is set to that of thebackground. For each voxel traversed, the source radiance of the voxelis first added into the current radiance. The transmittance τ due to thevoxel is computed and multiplied with the sum of the source radiance,weighted by the extinction cross section σ_(t) and the medium density Dat the voxel. This procedure is called compositing.

In compositing the source radiance, various degrees of approximation maybe taken. In the most basic (zero order) approximation, the compositingmay be based on a pure RBF approximation in which the source radiance,the transmittance and the density are all taken as that of a model RBFdensity. At the next level (first order) approximation, the densityitself is compensated by a residual density while the source radianceand transmittance in which the residual density may only play anindirect role are taken as that of a model RBF density. The first orderapproximation has proven to have significantly better result than thezero order approximation. Higher orders of approximation may also betaken to result in a further improvement, but the improvement may bemuch less than the improvement made in the first order approximation andmay not be worth the additional computational cost.

An example of ray marching using the above-described first orderapproximation to composite the source radiance is as follows:

$\begin{matrix}{\begin{matrix}{{L( {x,\omega_{o}} )} = {{{\tau( {x_{\omega_{o}},x} )}{L_{in}( \omega_{o} )}} + {\int_{x_{\omega_{o}}}^{x}{{\tau( {u,x} )}\sigma_{t}{D(u)}{J( {u,\omega_{o}} )}{\mathbb{d}u}}}}} \\{\approx {{{\overset{\sim}{\tau}( {x_{\omega_{o}},x} )}{L_{in}( \omega_{o} )}} + {\int_{x_{\omega_{o}}}^{x}{{\overset{\sim}{\tau}( {u,x} )}\sigma_{t}{D(u)}{\overset{\sim}{J}( {u,\omega_{o}} )}{\mathbb{d}u}}}}} \\{= {{{\overset{\sim}{\tau}( {x_{\omega_{o}},x} )}{L_{in}( \omega_{o} )}} + {\int_{x_{\omega_{o}}}^{x}{{\overset{\sim}{\tau}( {u,x} )}\sigma_{t}{{\overset{\sim}{J}}_{D}( {u,\omega_{o}} )}{\mathbb{d}u}}}}}\end{matrix}{where}} & (10) \\\begin{matrix}{{{\overset{\sim}{J}}_{D}( {u,\omega_{o}} )} = {{D(u)}{\overset{\sim}{J}( {u,\omega_{o}} )}}} \\{= {{D(u)}( {{{y( \omega_{o} )} \cdot \frac{1}{\overset{\sim}{D}(u)}}{\sum\limits_{\ell}{w_{\ell}{B_{\ell}(u)}{\overset{\sim}{J}( c_{\ell} )}}}} )}} \\{= {( {1 + \frac{R(u)}{\overset{\sim}{D}(u)}} ){( {{y( \omega_{o} )} \cdot {\sum\limits_{\ell}{w_{\ell}{B_{\ell}(u)}{\overset{\sim}{J}( c_{\ell} )}}}} ).}}}\end{matrix} & (11)\end{matrix}$

For efficient ray marching, the RBF volumes may be decomposed into Nslices 1206 of user-controllable thickness Δu along the current viewfrustum, as shown in FIG. 12.

The discrete integral of Eq. (10) is calculated slice by slice from backto front:

${{L( {x,\omega_{o}} )} = {{{L_{in}( \omega_{o} )}{\prod\limits_{j = 1}^{N}{\overset{\sim}{\tau}}_{j}}} + {\sum\limits_{i = 1}^{N}( {{{\overset{\sim}{J}}_{D}( u_{i} )}\sigma_{t}\Delta\; u{\prod\limits_{j = {i + 1}}^{N}{\overset{\sim}{\tau}}_{j}}} )}}},$

where {u_(i)} contains a point from each slice that lies on the viewray, γ is the angle between the view ray and the central axis of theview frustum, {tilde over (τ)}_(j) is the transmittance of slice j alongthe view ray, computed as{tilde over (τ)} _(j)=exp(−σ_(t) {tilde over (D)}(u _(j))Δu/cosγ).  (12)

With compensated ray marching, rendering results are generated with finedetails. A rendering based on the above compensated ray marching hasbeen compared with a rendering result with a ray traced image. In thecomparison, ray tracing is performed on the original density field,instead of the approximated RBF density field. The ray tracing resultappears slightly smoother than the compensated ray marching result,perhaps because the compensated ray marching with a first orderapproximation accounts for the residual in the ray march but not in thescattering simulation. The two results are nevertheless comparable.However, the compensated ray marching techniques described herein isadvantageous because it achieves real-time rendering, while in contrast,conventional ray tracing can only be performed off-line. The real-timerendering results have also been compared with the offline ray tracingwith different lighting conditions to demonstrate that the real-timerendering described herein is able to achieve results comparable to thatof the off-line ray tracing.

GPU Implementation—All run-time components of the algorithm describedherein can be efficiently implemented on the GPU using pixel shaders. Inthe following, some implementation details are described.

Single Scattering: Source radiances are directly computed at only theRBF centers. For single scattering computation, one exemplaryimplementation rasterizes a small 2D quad in which each RBF isrepresented by a pixel. In some embodiments, approximated density modeluses at most 1000 RBFs per frame, and accordingly a quad size of 32×32is sufficient. The RBF data (c_(l),r_(l),w_(l)) may be precomputed(e.g., either by a CPU on the same board with the GPU, or an externalCPU) is packed into a texture and passed to the pixel shader.

In the shader, for each pixel (i.e., RBF center) the algorithm iteratesthrough the RBFs to compute the transmittance vector {tilde over(τ)}(c_(l)) as described herein. Then the source radiance is computedusing the SH triple product and convolution according to Eq. (9).

Multiple Scattering: an overview of the GPU pipeline for multiplescattering is depicted FIG. 11. The incident radiance buffer 1102 isinitialized with the reduced incident radiance I¹ that has beencalculated for single scattering. Then for each iteration of thesimulation, the scattered source radiance {tilde over (J)}_(ms) ^(k) iscomputed at block 1104 using

${{{\overset{\sim}{J}}_{m\; s}^{k}( c_{\ell} )} = {\frac{{\alpha( c_{\ell} )}\Omega}{4\pi}( {{I^{k}( c_{\ell} )}*p} )}},$and accumulated in the source radiance buffer 1106. The exitant radianceE^(k) is computed at block 1108 usingE^(k)(c_(l))=(1−α(c_(l)))I^(k)(c_(l))+{tilde over (J)}_(ms) ^(k)(c_(l))and stored at exitant radiance buffer 1110. The exitant radiance E^(k)is used for estimate the subsequent incident radiance I^(k+1) using thepreviously described process H 1112 in alternation. The incidentradiance I^(k+1) may also stored in incident radiance buffer 1102. Themultiple rendering target and frame buffer object (FBO) of OpenGLextensions are used to avoid frame buffer readbacks.

Note that for the first iteration, the scattered source radiance is notaccumulated into {tilde over (J)}_(ms), and the initial exitant radianceis simply {tilde over (J)}_(ms) ¹. As in single scattering, oneexemplary implementation rasterizes a 2D quad of size 32×32 for eachoperation.

Ray Marching—The ray march starts by initializing the final color bufferwith the background lighting L_(in). Then from far to near, each slice iis independently rendered in two passes.

In the first pass, the OpenGL blend mode is set to GL_ONE for both thesource and target color buffers. The process that iterates over all theRBFs. For each RBF B_(l), its intersection with the slice is firstcalculated. This plane-to-sphere intersection can be efficientlycomputed given the center and radius of the sphere. If an intersectionexists, a 2D bounding quad is computed for the circular intersectionregion, and rendered this 2D quad.

For each pixel in the quad, denote its corresponding point in the volumeas u_(i). In the pixel shader, the density w_(l)B_(l)(u_(i)) isevaluated and saved in the alpha channel, and {tilde over(J)}_(D,l)(u_(i))=w_(l)B_(l)(u_(i))(y(ω_(o))·{tilde over (J)}(c_(l))) iscomputed and placed in the RGB channels. With the residual R(u_(i)) fromthe hash table, the process calculates and stores {tilde over(J)}_(D,l)(u_(i))R(u_(i)) in the RGB channels of a second color buffer.After the first pass, one thus has

${\sum\limits_{l}^{\;}\;{{\overset{\sim}{J}}_{D,l}( u_{i} )}},{\overset{\sim}{D}( u_{i} )},{{and}\mspace{14mu}{R( u_{i} )}{\sum\limits_{i}^{\;}\;{{\overset{\sim}{J}}_{D,l}( u_{i} )}}}$in the color buffers, which are sent to the second pass as texturesthrough the FBO.

In the second pass, the OpenGL blend mode is set to GL_ONE andGL_SRC_ALPHA for the source and final color buffers, respectively.Instead of drawing a small quad for each RBF as in the first pass, theexemplary process draws a large bounding quad for all RBFs thatintersect with the slice. In the pixel shader, {tilde over(J)}_(D)(u_(i)) for each pixel is evaluated according to Eq. (11) as

${{\overset{\sim}{J}}_{D}( u_{i} )} = {{\sum\limits_{l}^{\;}\;{{\overset{\sim}{J}}_{D,l}( u_{i} )}} + {( {{R( u_{i} )}{\sum\limits_{l}^{\;}\;{{\overset{\sim}{J}}_{D,l}( u_{i} )}}} )/{{\overset{\sim}{D}( u_{i} )}.}}}$

The RGB channels of the source buffer are then computed as {tilde over(J)}_(D)(u_(i))σ_(t)Δu/cos γ, and the alpha channel is set to {tildeover (τ)}_(i), computed using Eq. (12).

The residual R(u_(i)) is decoded by perfect spatial hashing as describedin Lefebvre, S. et al., 2006, “Perfect spatial hashing”, ACMTransactions on Graphics 25, 3, 579-588. Eight texture accesses areneeded in computing a trilinear interpolation. To avoid divide-by-zeroexceptions, residuals are set to zero during preprocessing when {tildeover (D)}(u) is very small (e.g., <1.0e−10).

Exemplary Results:

The above described algorithm has been implemented on a 3.7 GHz PC with2 GB of memory and an NVidia 8800GTX graphics card. Images are generatedat a 640×480 resolution.

Smoke Visualization—As a basic function, the present system allows usersto visualize smoke simulation results under environment lighting andfrom different viewpoints. The results with and without residualcompensation have been obtained and compared. Although both may beadequate for various purposes, images with finer details are obtainedwith compensated ray marching.

The optical parameters of the smoke can be edited in real time. Forexample, for images containing the same smoke density field andlighting, adjusting the albedo downward and increasing the extinctioncross section darkens the appearance of the smoke. For images with fixedlighting, changing the phase function from constant to theHenyey-Greenstein (HG) phase function (with eccentricity parameter 0.28,for example) also creates a different effect. The dependence of thescattered radiance on the view direction can also be seen.

Shadow Casting between Smoke and Objects—Combined with the sphericalharmonic exponentiation (SHEXP) algorithm for soft shadow rendering, themethod described herein can also render dynamic shadows cast between thesmoke and scene geometry. In one embodiment, the method is able toachieve real-time performance at over 20 fps for exemplary scenecontaining 36K vertices. For each vertex in the scene, the exemplaryembodiment first computes the visibility vector by performing SHEXP overthe accumulative log visibility of all blockers. Each RBF of the smokeis regarded as a spherical blocker whose log visibility is the opticaldepth vector as computed according to the methods described herein.Vertex shading is then computed as the triple product of visibility,BRDF and lighting vectors. After the scene geometry is rendered, thesource radiance is computed at RBF centers due to single scattering,taking the occlusions due to scene geometry into account using SHEXP.Finally, the multiple scattering simulation and compensated ray marchingare performed to generate the results.

Performance: TABLE 2 lists performance statistics for three examples.The preprocessing time (for precomputation) ranges from 1 to 3 hours,which is reasonably short. The residual hash tables are significantlysmaller than the original density field sequences.

TABLE 2 Exemplary Performance Results Scene A B C Volume grid  128³ 100³  100³ Frames 600 500 450 Avg. RBFs per 460 247 314 frame RBFapprox. RMS 2.48% 1.03% 1.34% error Decomposition 140  43  85 (min)Hashing (min)  35  18  20 Hash table (MB) 218  57  67 Performance (fps)19.1-95.1 36.4-57.8 35.8-74.8

In some exemplary implementations, the user can specify the maximumnumber of RBFs per frame for density approximation. An exemplary defaultvalue of 1000 works well for many situations. In principle, the sourceradiance at each voxel can be exactly reconstructed using a sufficientlylarge number of RBFs, but a limit on RBFs is needed in practice. Atradeoff between accuracy and performance requires a balance inpractice.

CONCLUSION

A method has been described for real-time rendering of inhomogeneouslight scattering media such as smoke animations. The method allows forinteractive manipulation of environment lighting, viewpoint, and smokeattributes. The method may be used for efficient rendering of bothstatic and dynamic participating media without requiring prohibitivelyexpensive computation or precomputation, making it suitable for editingand rendering of dynamic smoke. Based on a decomposition of smokevolumes, for example, the method utilizes a low-frequency density fieldapproximation to gain considerable efficiency, while incorporating finedetails in a manner that allows for fast processing with high visualfidelity. However, it is appreciated that the potential benefits andadvantages discussed herein are not to be construed as a limitation orrestriction to the scope of the appended claims.

Although the subject matter has been described in language specific tostructural features and/or methodological acts, it is to be understoodthat the subject matter defined in the appended claims is notnecessarily limited to the specific features or acts described. Rather,the specific features and acts are disclosed as exemplary forms ofimplementing the claims.

1. A method for rendering an inhomogeneous scattering medium representedby a density field comprising an approximate model density field and aresidual density field, the method performed by a processor thatexecutes acts comprising: computing an approximate source radiance basedon the approximate model density field; computing an effective exitantradiance by compositing the approximate source radiance by integratingthe approximate source radiance along a view ray in both the approximatemodel density field and the residual density field; and rendering animage of the inhomogeneous scattering medium based on the effectiveexitant radiance, wherein: the approximate model density field modelsthe density field of the inhomogeneous scattering medium; and theresidual density field is a difference between the density field and theapproximate model density field.
 2. The method as recited in claim 1,wherein compositing the approximate source radiance comprises performinga ray marching procedure including: decomposing a volume space of thedensity field into a plurality of slices along a central view frustum;and calculating a discrete integral of the approximate source radianceslice by slice.
 3. The method as recited in claim 2, wherein each slicehas a user-controllable thickness stacking along a current viewdirection, and the discrete integral is calculated slice by slice alonga current view direction.
 4. The method as recited in claim 1, whereinthe approximate model density comprises a radial basis functions (RBF)model density field which is expressed by a weighted sum of a set ofRBFs each having a RBF center.
 5. The method as recited in claim 4,wherein computing the approximate source radiance comprises: computing avalue of the approximate source radiance at each RBF center; andapproximating values of the approximate source radiance at other pointsin the volume space by interpolating from the values of the sourceradiance at the RBF centers.
 6. The method as recited in claim 1,wherein the residual density field is obtained by computing a differencebetween the density field and the approximate model density field. 7.The method as recited in claim 1, further comprising: zeroing entries ofthe residual density field at points where the residual density fieldhas a value at or below a given threshold.
 8. The method as recited inclaim 1, further comprising: compressing values of the residual densityfield.
 9. The method as recited in claim 1, further comprising:compressing values of the residual density field by performing a spatialhashing on values of the residual density field.
 10. The method asrecited in claim 1, wherein the inhomogeneous scattering mediumcomprises smoke.
 11. The method as recited in claim 1, wherein theinhomogeneous scattering medium is a part of a video or animationcomprising a sequence of renderings of images rendered at timeintervals, and wherein at least one of the approximate source radianceand the effective exitant radiance is computed in real time at each timeinterval.
 12. The method as recited in claim 11, wherein both theapproximate source radiance and the effective exitant radiance arecomputed in real time at each time interval.
 13. The method as recitedin claim 1, wherein computing the approximate source radiance comprisescomputing a single scattering term of the source radiance.
 14. Themethod as recited in claim 13, wherein computing the single scatteringterm comprises computing a spherical harmonic product and a convolutionterm[(L_(in)*{tilde over (τ)}(c_(l)))★p], wherein L_(in) is a vectorrepresenting a spherical harmonic projection of incident radianceL_(in), {tilde over (τ)}(c_(l)) is transmittance vector associated withRBF center c_(l), and p is a vector representing a spherical harmonicprojection of phase function p.
 15. The method as recited in claim 1,wherein computing the approximate source radiance comprises computing asingle scattering term and a multiple scattering term of the sourceradiance.
 16. A method for rendering an inhomogeneous scattering mediumrepresented by a density field comprising an approximate model densityfield and a residual density field, the method performed by a processorthat executes acts comprising: computing an approximate source radiancebased on the approximate model density field; computing a base componentof an effective exitant radiance by integrating the approximate sourceradiance along a view ray in the approximate model density field;computing a compensation component of the effective exitant radiance byintegrating the approximate source radiance along the view ray in theresidual density field; and rendering an image of the inhomogeneousscattering medium based on the effective exitant radiance, wherein: theapproximate model density field models the density field of theinhomogeneous scattering medium; and the residual density field is adifference between the density field and the approximate model densityfield.
 17. The method as recited in claim 16, wherein compositing theapproximate source radiance comprises performing a ray marchingprocedure including: decomposing a volume space of the density fieldinto a plurality of slices along a central view frustum; and calculatinga discrete integral of the approximate source radiance slice by slice.18. The method as recited in claim 16, wherein the approximate modeldensity comprises a radial basis functions (RBF) model density fieldwhich is expressed by a weighted sum of a set of RBFs each having a RBFcenter.
 19. The method as recited in claim 16, further comprising:zeroing entries of the residual density field at points where theresidual density field has a value at or below a given threshold; andcompressing the nonzero entries of the residual density field.
 20. Oneor more non-transitory storage medium having stored thereupon aplurality of instructions that, when executed by one or more processors,causes the processor(s) to: compute an approximate source radiance basedon the approximate model density field; compute an effective exitantradiance by compositing the approximate source radiance by integratingthe approximate source radiance along a view ray in both the approximatemodel density field and the residual density field; and render an imageof the inhomogeneous scattering medium based on the effective exitantradiance, wherein: the approximate model density field models a densityfield of the inhomogeneous scattering medium; and the residual densityfield is a difference between the density field and the approximatemodel density field.